/*****************************************************************************
 *
 * Copyright (c), 2004-2020,ShangHai Neotune Information Technology Co., Ltd.
 *
 * Module Name : etimer.h
 *
 * Author :    sean
 *
 * Date :    2004-02-05
 *
 * Version :    1.00
 *
 * Description :    
 *
 * Other :    
 *
 * Data Structure List: <Main Data Structure>
 *
 * Modification History
 * ---------------------------------------------------------------------------
 *  1: Data :      2004-02-05
 *    Author :     sean
 *    Version :    V100R001M00
 *    Modification : creation
 *
*****************************************************************************/


#if (!defined(etimer_inc))
#define etimer_inc

#ifdef __cplusplus
extern"C" {
#endif

#if (!defined snmp_inc)
#include <snmp.h>
#endif

/* timer structure. Timer memory allocation is expected to be managed by
 * code which calls into the timer system.
 *
 * Software using timers must call tm_init() on any timer before calling
 * any other tm_ functions on it.
 */

#ifdef NEOSNET_STRUCT_ALIGN
#pragma align 1
#endif

typedef struct ENVOY_TIMER_S {
        struct ENVOY_TIMER_S *link;     /* list link */
        bits32_t            expire;     /* relative expiration time in ms */
        void (*handler) __((struct ENVOY_TIMER_S *, void *));
                                        /* expiration handler */
        void               *cookie;     /* handler cookie */
        } ENVOY_TIMER_T;

/* structure that contains a 32 bit id so the memory can be allocated
   as a block, done here so that multiple routines can use it */
typedef struct ENVOY_TIMER_32_S {
        struct ENVOY_TIMER_S timer;
        bits32_t             id;
        } ENVOY_TIMER_32_T;

#ifdef NEOSNET_STRUCT_ALIGN
#pragma align 0
#endif

/* timer calls
 */

void envoy_tm_init      __((ENVOY_TIMER_T *));          /* init timer */
int  envoy_tm_set       __((ENVOY_TIMER_T *, bits32_t));/* set timer */
int  envoy_tm_cancel    __((ENVOY_TIMER_T *));          /* cancel timer */

/* global root pointer and init routine */
#if INSTALL_ENVOY_SNMP_LOCK
ENVOY_SNMP_LOCK_EXTERN(SNMP_TimerLock);
#endif
extern ENVOY_TIMER_T *envoy_timer_list;
void envoy_timer_init   __((void));

#ifdef __cplusplus
}
#endif

#endif /* etimer_inc */
